<!--
  智慧小区管理系统 - 页面容器组件
  @author Wu.Liang
  @date 2024-01-01
  @updated 2024-12-21 - 提供统一的页面布局容器
-->
<template>
  <div class="page-container">
    <!-- 页面头部 -->
    <div class="page-header" v-if="title || description || $slots.header">
      <div class="header-content">
        <div class="header-left">
          <h1 class="page-title" v-if="title">{{ title }}</h1>
          <p class="page-description" v-if="description">{{ description }}</p>
          <slot name="header" />
        </div>
        <div class="header-right">
          <slot name="header-actions" />
        </div>
      </div>
    </div>

    <!-- 页面内容 -->
    <div class="page-content" :class="{ 'no-padding': !padding }">
      <slot />
    </div>

    <!-- 页面底部 -->
    <div class="page-footer" v-if="$slots.footer">
      <slot name="footer" />
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  title?: string
  description?: string
  loading?: boolean
  padding?: boolean
}

withDefaults(defineProps<Props>(), {
  loading: false,
  padding: true
})
</script>

<style scoped>
.page-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
}

.page-header {
  padding: 24px 24px 0 24px;
  border-bottom: 1px solid #e8e8e8;
  background: #ffffff;
}

.header-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
}

.header-left {
  flex: 1;
  min-width: 0;
}

.page-title {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: #303133;
  line-height: 1.4;
}

.page-description {
  margin: 0;
  font-size: 14px;
  color: #606266;
  line-height: 1.5;
}

.header-right {
  flex-shrink: 0;
}

.page-content {
  flex: 1;
  padding: 24px;
  overflow: auto;
  min-height: 0;
}

.page-content.no-padding {
  padding: 0;
}

.page-footer {
  padding: 16px 24px;
  border-top: 1px solid #e8e8e8;
  background: #fafafa;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    padding: 16px 16px 0 16px;
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .page-title {
    font-size: 18px;
  }

  .page-description {
    font-size: 13px;
  }

  .page-content {
    padding: 16px;
  }

  .page-footer {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .page-header {
    padding: 12px 12px 0 12px;
  }

  .page-title {
    font-size: 16px;
  }

  .page-content {
    padding: 12px;
  }
}
</style> 